import {BrowserWindow} from "electron";

export function openDevTools(win: BrowserWindow) {
	let devtools = new BrowserWindow();
	devtools.setMenu(null);
	devtools.webContents.on("did-finish-load", () =>
		devtools.setTitle(win.webContents.getTitle())
	);
	win.webContents.setDevToolsWebContents(devtools.webContents);
	win.webContents.openDevTools({
		mode: "detach",
	});
	win.on("closed", () => {
		devtools?.close();
	});
	devtools.on("closed", () => {
		devtools = null;
	});
}
